package com.tianji.aigc.controller;

import com.tianji.aigc.dto.ChatDTO;
import com.tianji.aigc.service.impl.ChatServiceImpl;
import com.tianji.aigc.vo.ChatEventVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/chat")
public class ChatController {

    @Autowired
    private ChatServiceImpl chatService;
    /**
     * 聊天接口（流式输出）
     * @param dto
     * @return
     */
    @PostMapping
    public Flux<ChatEventVO> chat(@RequestBody ChatDTO dto) {
        return chatService.chat(dto);
    }
    /**
     * 停止生成
     */
    @PostMapping("stop")
    public void stop(String sessionId) {
        chatService.stop(sessionId);
    }
}
